package com.tj.collection.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 上午10:44
 */
public enum UserContactFriendTypeEnum {
    FRIEND(1, "Friend"),
    COLLEAGUE(2, "Colleague"),
    ;

    private Integer type;
    private String desc;

    UserContactFriendTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public UserContactFriendTypeEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public UserContactFriendTypeEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (UserContactFriendTypeEnum enumObj : UserContactFriendTypeEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static UserContactFriendTypeEnum getEnumByType(Integer type) {
        UserContactFriendTypeEnum userContactFriendTypeEnum = null;
        for (UserContactFriendTypeEnum enumObj : UserContactFriendTypeEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userContactFriendTypeEnum = enumObj;
                break;
            }
        }

        return userContactFriendTypeEnum;
    }

    public static UserContactFriendTypeEnum getEnumByDesc(String desc) {
        UserContactFriendTypeEnum userContactFriendTypeEnum = null;
        for (UserContactFriendTypeEnum enumObj : UserContactFriendTypeEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userContactFriendTypeEnum = enumObj;
                break;
            }
        }
        return userContactFriendTypeEnum;
    }
}
